On an infinite chequered board there is a superknight which can make different
moves. Each kind of move is described by two integers: the first tells how many
columns (to the right if the number is positive or to the left if the number is
negative) and the second tells how many rows (forward if the number is positive
or backward if the number is negative) the knight traverses making such a move.
Task
Write a program which:
reads from the standard input sets of data describing different
superknights,
determines for each superknight whether it is able to reach any square of
the board making allowed moves,
writes the result to the standard output.
Input
In the first line of the standard input there is one integer
denoting the number of sets of data, . It is
followed by sets of data. In the first line of each set there is an
integer being the number of kinds of the superknight's moves,
. Each of the following lines of the
set contains two integers and separated by a single
space, . These numbers describe
one kind of move.
Output
The standard output should consist of lines. The -th
line should contain one word TAK ("yes"), if the superknight
described by the -th set of data is able to reach any square of the
board, or the word NIE ("no") otherwise.
Example
For the input data:
2
3
1 0
0 1
-2 -1
5
3 4
-3 -6
2 -2
5 6
-1 4
the correct result is:
TAK
NIE
Task author: Krzysztof Onak.
Kontakt
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.